/*
 * @Date: 2022-02-11 16:30:38
 * @LastEditors: tich425
 * @LastEditTime: 2022-02-11 16:30:39
 * @FilePath: \TodoList\utils\user.go
 * @Description: 用户管理
 */
package utils

import (
	"todo-list/global"
	"todo-list/model"
)

/**
 * @description: 判断用户名是否存在
 * @param {string} username
 */
func IsUsernameExist(username string) bool {
	var count int64
	global.MYSQL_DB.Model(model.User{}).Where("username = ?", username).Count(&count)
	return count > 0
}

/**
 * @description: 判断邮箱是否存在
 * @param {string} email
 */
func IsEmailExist(email string) bool {
	var count int64
	global.MYSQL_DB.Model(model.User{}).Where("email = ?", email).Count(&count)
	return count > 0
}
